package com.godofgamblers.hotelmanagementsystem.mapper;

import com.godofgamblers.hotelmanagementsystem.pojo.User;
import com.godofgamblers.hotelmanagementsystem.pojo.Worker;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/*

@author huanglang

@create_time 2019-10-15 12:14

Nothing is difficult but bugs

*/
@Repository
public interface WorkingMapper {

    @Select("SELECT user_account,user_phone,user_image,work_time,off_work_time\n" +
            "FROM `user` u,working w\n" +
            "WHERE u.user_id=w.user_id AND work_time LIKE #{today}")
    public Worker getTodayWorker(String today);

    @Insert("INSERT INTO working (user_id,work_time) VALUES(#{user_id},#{work_time})")
    public void setTodayWorker(Map<String, Object> map);

    @Update("UPDATE working SET off_work_time=#{off_work_time} WHERE user_id=#{user_id}")
    void setTodayWorkerOff(Map<String, Object> map);
}
